package com.example.java.designpattern;

/**
 * @author zengty
 * @apiNote 代理模式
 * @date 2024/8/29
 * @project study
 */
public class ProxyDivisor implements Divisor{

    private final Divisor divisor;

    /**
     * 代理模式需要构造器
     */
    public ProxyDivisor(Divisor divisor) {
        this.divisor = divisor;
    }

    @Override
    public void divide(String s) {
        System.out.println("ProxyDivisor.divide");
        divisor.divide(s);
        System.out.println("ProxyDivisor.divide");
    }

    @Override
    public boolean isSupport(String target) {
        return divisor.isSupport(target);
    }
}
